package com.ktg.mes.atuoVue;


import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

@Data
@Accessors(chain = true)
public class TableColumn {

    private String name;
    private String prop;
    private Integer width;
    private String align = "center" ;

    /**
     *  设置颜色 如：#AAAAAA
     */
    private String background;

    private String fixed;

    private String textColor;

    /**
     *  下降标题列表
     */
    private List<TableColumn> subColumns;

    /**
     *  操作按钮
     */
    private List<VueButtom> vueButtoms;
    public TableColumn(String name,String prop){
        initData(name,prop,null);
    };


    public TableColumn(String name,String prop,Integer width){
        initData(name,prop,width);
    };

    public void initData(String name,String prop,Integer width){
        this.name = name;
        this.prop = prop;
        this.width =width;
        this.setAlign(AlignType.Center);
    }



    public TableColumn setName(String name) {
        this.name = name;
        return this;
    }

    public TableColumn setProp(String prop) {
        this.prop = prop;
        return this;
    }

    public TableColumn setWidth(Integer width) {
        this.width = width;
        return this;
    }

    public TableColumn setAlign(AlignType type){
        this.align = type.value;
        return this;
    }

    public TableColumn setBackground(String background) {
        this.background = background;
        return this;
    }

    public TableColumn setFixed(String fixed) {
        this.fixed = fixed;
        return this;
    }

    public TableColumn addVueButtom(VueButtom buttom){
        if (this.vueButtoms == null){
            this.vueButtoms = new ArrayList<>();
        }
        this.vueButtoms.add(buttom);
        return this;
    }
    public enum AlignType {

        Center("center"),Left("left"),Right("right");

        private final String value;

        AlignType(String value)
        {
            this.value = value;
        }

        public String value()
        {
            return this.value;
        }
    }

}
